//---------------------------------------------------------------------------

#ifndef CSpeedBtnH
#define CSpeedBtnH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <memory>
#include <Buttons.hpp>
#include "CBitbtn.h"

class PACKAGE CSpeedButton : public TSpeedButton
{
__published:
  __property CBitBtnKind Kind = {read=FKind, write=SetKind, default=Cbitbtn::bkCustom};
	__property Graphics::TBitmap* Glyph = {read = GetGlyph, write = SetGlyph, stored = GetGlyphStored};

private:
   CBitBtnKind FKind;
//	Graphics::TBitmap* GlyphInactif;

   bool __fastcall GetGlyphStored()
     {
       return FKind == Cbitbtn::bkCustom;
     }
    Graphics::TBitmap* __fastcall GetGlyph(void)
     {
       return TSpeedButton::Glyph;
     }
	 void __fastcall SetGlyph(Graphics::TBitmap* Value);

    CBitBtnKind __fastcall GetKind(void);
    void __fastcall SetKind(CBitBtnKind Value);
    MESSAGE void __fastcall CNDrawItem(TMessage& Msg);
//    void __fastcall SetGlyphInactif(Graphics::TBitmap *GlyphActif);
  void __fastcall CalcButtonLayout(TCanvas *Canvas, const TRect &Client,const AnsiString &Caption,TButtonLayout Layout,int Margin,  int Spacing, TPoint *GlyphPos, TRect *TextBounds);
  void __fastcall DoDrawButtonText(TCanvas* Canvas,
                                 const TRect &ClientRect,
                                 TColor Color,
                                 TColor FontColor,
                                 const AnsiString &aCaption,
                                 CBitBtnKind Kind,
                                 Graphics::TBitmap *Glyph,
                                 int Margin,
                                 int Spacing,
                                 const TOwnerDrawState& state,
                                 const TPoint &LePoint);
void __fastcall DoDrawButtonGlyph(TCanvas* Canvas,
                                  const TRect &ClientRect,
                                  TColor Color,
                                  const AnsiString &aCaption,
                                  CBitBtnKind Kind,
                                  Graphics::TBitmap *Glyph,
                                  int Margin,
                                  int Spacing,
                                  const TOwnerDrawState& state,
                                  const TPoint &LePoint);

public:
    BEGIN_MESSAGE_MAP
        MESSAGE_HANDLER(WM_PAINT, TMessage, CNDrawItem)
    END_MESSAGE_MAP(TSpeedButton)

  __fastcall CSpeedButton(TComponent* Owner);
  __fastcall ~CSpeedButton();
};
//---------------------------------------------------------------------------
#endif
